package com.qf.servlet;

import com.qf.entity.Classes;
import com.qf.service.ClassesService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 班级查询的servlet
 * description:
 * author: Ken
 * 公众号：Java架构栈
 */
@WebServlet(urlPatterns = "/classsequery")
public class ClassesQueryServlet extends HttpServlet {

    private ClassesService classesService = new ClassesService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //查询所有的班级信息 - service
        List<Classes> classes = classesService.queryCls();
        //request?-转发 session?-重定向
        req.setAttribute("cls", classes);
        //转发到班级列表页面
        req.getRequestDispatcher("classeslist.jsp").forward(req, resp);
    }
}
